CHARTS
Photo by Annie Spratt on Unsplash
As a single mum you’ll discover inner strengths and capabilities you never knew you had…
— Emma-Louise Smith
url_root <- "https://raw.githubusercontent.com/UN-AVT/kamino-source/main/sources/0-shared/data/"
url_file <- "worlds-women-report/figure-4-8_db.csv"
url <- paste0(url_root, url_file)
df <- read.csv(url, header = TRUE, stringsAsFactors = FALSE) # read text file
df
# sort values and refactor
df <- df %>% arrange(desc(y1_axis)) %>% mutate(x_axis=factor(x_axis, levels=x_axis))
# create dumbbell plot
v1<-ggplot(df) +
geom_segment( aes(x = x_axis, xend = x_axis, y = y1_axis, yend = y2_axis), lineend = "butt", linejoin = "round", size=3.5, color="#d9d9d9" ) +
geom_point( aes(x = x_axis, y = y2_axis), size=3, color="#5c96d6" ) +
geom_text( aes(x = x_axis, y = y2_axis, label=y2_axis), size=3, color="black", vjust = 2.5, fontface = "bold" ) +
geom_point( aes(x = x_axis, y = y1_axis), size=3, color="#692c7d" ) +
geom_text( aes(x = x_axis, y = y1_axis, label = y1_axis), size=3, color="black", vjust = -1.5, fontface = "bold" ) +
scale_y_continuous(limits = c(0,60), breaks = c(0, 20, 40, 60), labels = c(0, 20, 40, 60)) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
theme( # remove the vertical grid lines
panel.grid.major.x = element_blank(),
# explicitly set the horizontal lines (or they will disappear too)
panel.grid.major.y = element_line( size=.1, color="#cccccc" ),
panel.grid.minor.y = element_blank()
) +
labs(title = "POVERTY RATES AMONG LONE-PARENTS BEFORE AND AFTER TRANSFERS - Figure 4.8",
subtitle = "SELECTED COUNTRIES, LATEST AVAILABLE YEAR", caption = "Source: UN Women",
x = "",
y = "Percentage")
girafe(ggobj = v1, width_svg = 16, height_svg = 9,
options = list(opts_sizing(rescale = TRUE, width = 1.0)))
# create dumbbell plot
v2 <- ggplot(df) +
geom_point( aes(x = x_axis, y = y2_axis), size=3, color="#5c96d6" ) +
geom_point( aes(x = x_axis, y = y1_axis), size=3, color="#692c7d" )
girafe(ggobj = v2, width_svg = 20, height_svg = 9,
options = list(opts_sizing(rescale = TRUE, width = 1.0)))
# create dumbbell plot
v3 <- ggplot(df) +
geom_segment( aes(x = x_axis, xend = x_axis, y = y1_axis, yend = y2_axis), lineend = "butt", linejoin = "round", size=3.5, color="#d9d9d9" ) +
geom_point( aes(x = x_axis, y = y2_axis), size=3, color="#5c96d6" ) +
geom_point( aes(x = x_axis, y = y1_axis), size=3, color="#692c7d" )
girafe(ggobj = v3, width_svg = 20, height_svg = 9,
options = list(opts_sizing(rescale = TRUE, width = 1.0)))
# create dumbbell plot
v4 <- ggplot(df) +
geom_segment( aes(x = x_axis, xend = x_axis, y = y1_axis, yend = y2_axis), lineend = "butt", linejoin = "round", size=3.5, color="#d9d9d9" ) +
geom_point( aes(x = x_axis, y = y2_axis), size=3, color="#5c96d6" ) +
geom_text( aes(x = x_axis, y = y2_axis, label=y2_axis), size=3, color="black", vjust = 2.5, fontface = "bold" ) +
geom_point( aes(x = x_axis, y = y1_axis), size=3, color="#692c7d" ) +
geom_text( aes(x = x_axis, y = y1_axis, label = y1_axis), size=3, color="black", vjust = -1.5, fontface = "bold" )
girafe(ggobj = v4, width_svg = 20, height_svg = 9,
options = list(opts_sizing(rescale = TRUE, width = 1.0)))
# sort values and refactor
df <- df %>% arrange(desc(y1_axis)) %>% mutate(x_axis=factor(x_axis, levels=x_axis))
# create dumbbell plot
v5 <- ggplot(df) +
geom_segment( aes(x = x_axis, xend = x_axis, y = y1_axis, yend = y2_axis), lineend = "butt", linejoin = "round", size=3.5, color="#d9d9d9" ) +
geom_point( aes(x = x_axis, y = y2_axis), size=3, color="#5c96d6" ) +
geom_text( aes(x = x_axis, y = y2_axis, label=y2_axis), size=3, color="black", vjust = 2.5, fontface = "bold" ) +
geom_point( aes(x = x_axis, y = y1_axis), size=3, color="#692c7d" ) +
geom_text( aes(x = x_axis, y = y1_axis, label = y1_axis), size=3, color="black", vjust = -1.5, fontface = "bold" ) +
scale_y_continuous(limits = c(0,60), breaks = c(0, 20, 40, 60), labels = c(0, 20, 40, 60)) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
theme( # remove the vertical grid lines
panel.grid.major.x = element_blank(),
# explicitly set the horizontal lines (or they will disappear too)
panel.grid.major.y = element_line( size=.1, color="#cccccc" ),
panel.grid.minor.y = element_blank()
) +
labs(title = "POVERTY RATES AMONG LONE-PARENTS BEFORE AND AFTER TRANSFERS - Figure 4.8",
subtitle = "SELECTED COUNTRIES, LATEST AVAILABLE YEAR", caption = "Source: UN Women",
x = "",
y = "Percentage")
girafe(ggobj = v5, width_svg = 16, height_svg = 9,
options = list(opts_sizing(rescale = TRUE, width = 1.0)))
@misc{unwomen_2019_progress,
author = {UN Women},
title = {Progress of the world’s women | Digital library},
url = {https://www.unwomen.org/en/digital-library/progress-of-the-worlds-women},
urldate = {2021-06-11},
year = {2019},
organization = {UN Women}
}